package me.zhengjie.modules.quartz.task;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import me.zhengjie.modules.quartz.service.RestService;
import me.zhengjie.modules.quartz.service.dto.RestTaskConfig;
import org.springframework.stereotype.Component;

/**
 * 请求接口用的task
 * @author Zheng Jie
 * @date 2019-01-08
 */
@Slf4j
@Component
public class RestTask {

    private RestService restService;

    public RestTask(RestService restService) {
        this.restService = restService;
    }

    public String run(String param) {
        RestTaskConfig config = JSON.parseObject(param, RestTaskConfig.class);
        return restService.doRun(config);
    }
}
